package ControlLayer;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class AddressCtrTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class AddressCtrTest
{
    /**
     * Default constructor for test class AddressCtrTest
     */
    public AddressCtrTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void testCRUD()
    {
        ControlLayer.AddressCtr addressC1 = ControlLayer.AddressCtr.getInstance();
        assertNull(addressC1.getPerson(1));
        assertNull(addressC1.findPerson("a"));
        addressC1.createPerson("a", "b", "c", "d", "e");
        assertNotNull(addressC1.getPerson(1));
        assertNotNull(addressC1.findPerson("a"));
        ModelLayer.Person person1 = addressC1.findPerson("a");
        assertEquals("a", person1.getName());
        assertEquals("b", person1.getAddress());
        assertEquals("c", person1.getPostalCode());
        assertEquals("d", person1.getCity());
        assertEquals("e", person1.getPhone());
        addressC1.updatePerson(1, "aa", "bb", "cc", "dd", "ee");
        assertEquals("aa", person1.getName());
        assertEquals("bb", person1.getAddress());
        assertEquals("cc", person1.getPostalCode());
        assertEquals("dd", person1.getCity());
        assertEquals("ee", person1.getPhone());
        addressC1.deletePerson(1);
        assertNull(addressC1.getPerson(1));
    }
}

